package com.sy.pet.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sy.pet.commom.ResultBean;
import com.sy.pet.dto.PageDTO;
import com.sy.pet.dto.PetTagDTO;
import com.sy.pet.dto.PetTypeDTO;
import com.sy.pet.entity.PetTag;
import com.sy.pet.entity.PetType;
import com.sy.pet.service.PetTagService;
import com.sy.pet.service.PetTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author: liangSY
 * @Date: 2024/9/14
 * @ClassName: PetTagController
 * @Description: PetTagController描述
 */
@RequestMapping("/admin/pet/type")
@RestController
public class PetTypeController {

    @Autowired
    PetTypeService petTypeService;

    @PostMapping("/page")
    public ResultBean<IPage<PetType>> getByPage(@RequestBody @Valid PageDTO dto) {
        IPage<PetType> page = petTypeService.getByPage(dto);
        return ResultBean.success(page);
    }


    @DeleteMapping("/{id}")
    private ResultBean<String> removeUser(@PathVariable("id") String id){
        petTypeService.remove(id);
        return ResultBean.success();
    }

    @PutMapping
    private ResultBean<String> editTag(@RequestBody @Valid PetTypeDTO dto){
        petTypeService.edit(dto);
        return ResultBean.success();
    }

    @PostMapping
    private ResultBean<String> addTag(@RequestBody @Valid PetTypeDTO dto){
        petTypeService.add(dto);
        return ResultBean.success();
    }
}
